/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanChoixJoueur.java
 *
 * Created on 17 janv. 2012, 22:26:44
 */
package InterfaceGraphique.popupChoix;

import InterfaceGraphique.MainApplication;
import cartes.Carte;
import plateau.Joueur;

/**
 *
 * @author Arthur
 */
public class PanChoixJoueur extends javax.swing.JPanel {

    private Joueur joueur;
    private Carte carte;
    
    /** Creates new form PanChoixJoueur */
    public PanChoixJoueur() {
        initComponents();
    }
            
    public PanChoixJoueur(Joueur j, Carte c) {
        initComponents();
        this.carte = c;
        this.joueur = j;
        
        this.lNom.setText(joueur.getNom());
        this.lNiveau.setText(joueur.getNiveau() + "");
        this.validate();
        this.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        lNom = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lNiveau = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        jLabel1.setText("Nom : ");
        jLabel1.setName("jLabel1"); // NOI18N

        lNom.setText("jLabel2");
        lNom.setName("lNom"); // NOI18N

        jLabel2.setText("Niveau :");
        jLabel2.setName("jLabel2"); // NOI18N

        lNiveau.setText("jLabel3");
        lNiveau.setName("lNiveau"); // NOI18N

        jButton1.setText("Utiliser !");
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lNom)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(lNiveau)
                .addGap(33, 33, 33)
                .addComponent(jButton1)
                .addGap(31, 31, 31))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lNom)
                    .addComponent(jLabel2)
                    .addComponent(lNiveau)
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.carte.utiliser(MainApplication.getJoueurEnCours(), this.joueur);
        MainApplication.getJoueurEnCours().defausserCarteMain(carte);
        MainApplication.endAction();
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel lNiveau;
    private javax.swing.JLabel lNom;
    // End of variables declaration//GEN-END:variables

    public void set( Joueur j, Carte c) {
        this.carte = c;
        this.joueur = j;
        
        this.lNom.setText(joueur.getNom());
        this.lNiveau.setText(joueur.getNiveau() + "");
        this.validate();
        this.repaint();
    }
}
